<?php
global $_GPC, $_W;
$uniacid = $_W['uniacid'];
$id = $_GPC['id'];
$res = $this->res;
$plus = $this->plus;
load()->func('tpl');
$setting = $this->baseset($uniacid);
$settings = $this->module['config'];
$allcate = pdo_fetchall("SELECT * FROM " . tablename($this->tablecate) . " WHERE uniacid = '{$_W['uniacid']} ' AND status=1 order by displayorder desc");
$show = pdo_fetch("SELECT * FROM " . tablename($this->tableitem) . " WHERE uniacid = '{$_W['uniacid']}' AND id = '{$id}' AND status=1");
$fav = $this->getfav($openid, $show['id']);
$favall = $this->getfavall($show['id']);
$favtongji = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->tablefav) . " WHERE uniacid = '{$uniacid}' AND itemid = '{$show['id']}' ");
if (empty($favtongji)) {
	$favtongji = 0;
}
$jiage = $show['itemfee'];
$tag = $show['itemyhj_tit'];
if ($tag == '无') {
	$tag = '抢购';
} else {
	$tag = str_replace("", "", $tag);
}
$toptag = $show['itemyhj_tit'];
if (strpos($toptag, "减") > 0) {
	$pattern = '/减(.*)元/isU';
	preg_match($pattern, $toptag, $match);
	$toptag = "领券 " . $match[1] . " 元";
	$jiagenew = $jiage - $match[1];
	if ($jiagenew <= 0) {
		$jiagenew = $show['itemfee'];
	}
} elseif (strpos($toptag, "条") > 0) {
	$pattern = '/(.*)元/isU';
	preg_match($pattern, $toptag, $match);
	$toptag = "领券 " . $match[1] . " 元";
	$tag = '卷后价';
	$jiagenew = $jiage - $match[1];
	if ($jiagenew <= 0) {
		$jiagenew = $show['itemfee'];
	}
} else {
	$toptag = '抢购';
	$jiagenew = $jiage;
}
$yhjetime = strtotime($show['itemyhj_etime']);
$nowtime = time();
if ($nowtime - $yhjetime >= 0) {
	$daoqi = 1;
	$toptag = '抢购';
	$jiagenew = $jiage;
	$ison = 0;
} else {
	$ison = 1;
}
$_share['title'] = $show['title'];
$_share['imgUrl'] = tomedia($show['itempic']);
$_share['desc'] = $show['title'];
$_share['link'] = $_W['siteroot'] . "app/index.php?i=" . $_W['uniacid'] . "&c=entry&op=yhj&do=show&m=bsht_tbk&id=" . $show['id'];
$_W['page']['sitename'] = $show['title'];
$pagename = '商品详情';
if ($_W['container'] != 'wechat' && $_W['os'] == 'mobile') {
	if ($_GPC['op'] == 'yhj' || $_GPC['op'] == 'share' || $_GPC['op'] == 'view' || empty($_GPC['op'])) {
		$jumpurl = $show['itemyhj_url'];
		if (empty($jumpurl)) {
			$jumpurl = $show['itemurl'];
		}
		Header('HTTP/1.1 303 See Other');
		Header("Location: $jumpurl");
		exit;
	} else {
		$jumpurl = $show['itemsurl'];
		Header('HTTP/1.1 303 See Other');
		Header("Location: $jumpurl");
	}
}
include $this->template('show');